package com.smileymedia.core;

import android.content.Context;
import android.graphics.Rect;
import android.view.Display;
import android.view.WindowManager;

import com.smileymedia.smil.content.SmilRegion;


/**
 * Simple layout engine responsible for laying out components on the screen
 * @author greg
 *
 */
public class LayoutEngine {
	int mScreenWidth=0;
	int mScreenHeight=0;
 
	
	public LayoutEngine(Context context){
		Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
		
		mScreenWidth= display.getWidth(); 
		mScreenHeight= display.getHeight();
	}
	
	/**
	 * Calculate position of where the new region will be placed on the screen.
	 * @param region
	 * @return
	 */
	public Rect calculate(SmilRegion region) {
		if(region == null){
			throw new IllegalArgumentException("Region can't be null fix yourself");
		}
		Rect rectangle=new Rect();
		switch(region.type){
		case PERCENTS : {
			break;
		}
		//Pixels are simple simply copy from region to Rect
		case  PIXELS : {
			rectangle.left=region.left;
			rectangle.top=region.top;

			rectangle.right=region.left+region.width;
			rectangle.bottom=region.top+region.height;							
		}
		}

		return rectangle;
	}

}
